package com.chushouya.controller.product.admin;


import com.chushouya.common.constant.ServiceType;
import com.general.framework.core.schema.Response;
import com.chushouya.product.dto.admin.product.ProductSaveDTO;
import com.chushouya.product.service.admin.ProductCreateService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@Api(tags = ServiceType.PLATFORM + "商品新增模块")
@RestController
@RequestMapping(ServiceType.PLATFORM + "/productCreate")
public class ProductCreateController {

    @Resource
    private ProductCreateService productCreateService;
//
//    @Resource
//    private CategoryBrandService categoryBrandService;
//
//    @Resource
//    private ProductSeriesService productSeriesService;
//
//    @Resource
//    private ProductAttrService productAttrService;
//
//    @Resource
//    private CategoryService categoryService;
//
//    @Resource
//    private CategoryAttrService categoryAttrService;

    @ApiOperation("初始化新增信息")
    @PostMapping("/initCreate")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "categoryId", value = "类目id", required = true),
            @ApiImplicitParam(name = "brandId", value = "品牌id", required = true),
            @ApiImplicitParam(name = "seriesId", value = "系列id")
    })
    public Response<ProductSaveDTO> initCreate(Long categoryId, Long brandId, Long seriesId) {
        return Response.success(productCreateService.initCreate(categoryId, brandId, seriesId));
    }
//
//    @ApiOperation("获取分类-品牌SKU规格属性")
//    @GetMapping("/listSkuCategoryAttr")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "categoryId", value = "类目id", required = true),
//            @ApiImplicitParam(name = "brandId", value = "品牌id", required = true),
//            @ApiImplicitParam(name = "productId", value = "商品id", required = true)
//    })
//    public Response<List<CategoryAttrListDTO>> listSkuCategoryAttr(Long categoryId, Long brandId, Long productId) {
//        return Response.success(productAttrService.listProductCategorySkuAttr(productId, categoryId, brandId));
//    }
//
//    @ApiOperation("根据ID查询商品编辑页详情")
//    @GetMapping("/getDetail4Edit")
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "productId", value = "商品id")
//    })
//    public Response<ProductSaveDTO> getDetail4Edit(Long productId) {
//        return Response.success(productCreateService.getProductDetail4Edit(productId));
//    }
//
//    @ApiOperation("保存SKU规格属性自定义值")
//    @Log(businessType = BusinessType.INSERT)
//    @PostMapping("/saveCustomSkuAttrValue")
//    @RepeatSubmit
//    public Response<CategoryAttrValueDTO> saveCustomSkuAttrValue(@Validated @RequestBody CustomSkuAttrValueSaveDTO customSkuAttrValue) {
//        return Response.success(categoryAttrService.saveCustomSkuAttrValue(customSkuAttrValue));
//    }
//
//    @ApiOperation("删除SKU规格属性自定义值")
//    @Log(businessType = BusinessType.DELETE)
//    @DeleteMapping("/deleteCustomSkuAttrValue")
//    @RepeatSubmit
//    @ApiImplicitParams({
//            @ApiImplicitParam(name = "productId", value = "商品id", required = true),
//            @ApiImplicitParam(name = "valueId", value = "属性值id", required = true),
//    })
//    public Response<Void> deleteCustomSkuAttrValue(Long productId, Long valueId) {
//        categoryAttrService.deleteCustomSkuAttrValue(productId, valueId);
//        return Response.success();
//    }
//
    @ApiOperation("保存商品")
    @PostMapping("/edit")
    public Response<Long> edit(@Validated @RequestBody ProductSaveDTO product) {
        return Response.success(productCreateService.saveProduct(product));
    }

}
